function Queue(...arg) {
  var length = arguments.length;
  this.first = {};
  this.last = {};
}

Queue.prototype.length = function () {
  return this.length;
};
Queue.prototype.isEmpty = function () {
  return this.length === 0;
};
Queue.prototype.remove = function () {
  return this.first = null;
};
Queue.prototype.push = function (...arg) {
  this.length += arguments.length;
  for (var i = 0; i < arguments.length; i++) {
    if (this.last.value) {
      var obj =  this.last;
      obj.next = this.last = {
        value:arguments[i]
      }
    } else {
      var obj = {
        value:arguments[i]
      }
      this.last = this.first = obj;
    }
  }
};
Queue.prototype.front = function () {
  var obj = this.first;
  this.first = obj.next;
  this.length--;
  return obj;
};
Queue.prototype.print = function () {
  var obj = this.first;
  if(obj){
    console.log(JSON.stringify(obj.value));
    obj = obj.next;
  }
  while (obj){
//    console.log(this.length());
    console.log(JSON.stringify(obj.value));
    obj = obj.next;
  } ;
};

var obj = new Queue();
obj.push('a');
obj.push('b');
obj.push('c');
obj.push('d');
obj.push('1');
obj.push('2');
obj.push('3');
obj.print();














